package pl.com.qapps.datastore.berkeley;

import java.util.Arrays;

import pl.com.qapps.datastore.BytesHelper;
import pl.com.qapps.datastore.Datastore;
import pl.com.qapps.datastore.GaeHelper;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.KeyFactory;

public class DatastoreServiceTest {

	public static void main(String[] args) throws Exception {
		GaeHelper.registerEnvironment();

		Entity e1 = new Entity("Car", 1);
		System.out.println(KeyFactory.keyToString(e1.getKey()));
		System.out.println(Arrays.toString(BytesHelper.serialize(e1.getKey())));

		Datastore ds = BerkeleyDatastore.newLocal("./datastore");
		DatastoreService service = ds.getDatastoreService(null);

		service.put(e1);

		System.out.println(service.get(e1.getKey()));
		ds.close();

	}

}
